package ch.rheintalconnection.sysventory.application;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import ch.rheintalconnection.sysventory.businessServices.DataService;
import ch.rheintalconnection.sysventory.domain.ScanEntry;

public class SearchCommand {

	private DataService dataService;

	public SearchCommand(DataService dataService) {
		this.dataService = dataService;
	}

	public List<PCDatas> search(HashMap<PCAttribute, String> searchStrings) {

		List<PCDatas> pcdataslist = new ArrayList<PCDatas>();
		
		List<ScanEntry> scans = dataService.getFilteredNewestScanEntries(
				searchStrings.get(PCAttribute.PCName),
				searchStrings.get(PCAttribute.NICIP),
				searchStrings.get(PCAttribute.CPUFamily),
				searchStrings.get(PCAttribute.PCType),
				searchStrings.get(PCAttribute.OSName));

		
		for (ScanEntry scanEntry : scans) {
			pcdataslist.add(new PCDatas(scanEntry));
		}
		return pcdataslist;
	}

	// In dieser Methode können die SearchStrings vorgängig validiert werden.
	public boolean validateSearchStrings(
			HashMap<PCAttribute, String> searchStrings) {

		return true;
	}
}
